package org.frankkie.parcdroid;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
import java.util.ArrayList;

class OverlayDing extends ItemizedOverlay {

  private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
  MainActivity deMainActivity;
  //private List items = new ArrayList();
  //private Drawable marker = null;
  //public static
  public void wisDeOverlays() {
    //mOverlays = new ArrayList<OverlayItem>();
    mOverlays.clear();
    populate();
  }

  public OverlayDing(Drawable marker, MainActivity a) {
    super(boundCenterBottom(marker));
    deMainActivity = a;
    //super(marker);
    //this.marker = marker;

    //populate();
  }

  public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
  }

  @Override
  protected OverlayItem createItem(int i) {
    return mOverlays.get(i);
  }

  public static GeoPoint getPoint(double a, double b) {
    //return new GeoPoint(a, b);
    return new GeoPoint((int) (a * 1E6), (int) (b * 1E6));
  }

  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, shadow);
    //boundCenterBottom(marker);
  }

  @Override
  protected boolean onTap(int i) {
    OverlayItem ding = mOverlays.get(i);
    System.out.println("OverlayDing.onTap("+i+")\n"+ding.getTitle() + "\n" + ding.getSnippet()+";");
    deMainActivity.maakTosti(ding);
    return (true);
  }

  @Override
  public int size() {
    return mOverlays.size();
  }
}
